﻿
using Controller.i18n.entity;
using HBase;
using hCommand;
using hconnect;
using Persistence;
using System;
using System.Collections.Generic;

namespace Controller
{
    public class CarrierConnect1 : AbsTaskConnect
    {

       
        public CarrierConnect1() : base()
        {
           
        }


        protected override bool send(object task, int begin)
        {
            TaskCarrier taskCarrier = (TaskCarrier)task;
            //if (taskCarrier.des == -1)
            //{
            //    //退料
            //    writeShort(2, (short)(begin + 4), 2);
            //    return true;
            //}

            //writeByteArr(2, (short)begin, S7ByteUtil.toS7L4(taskCarrier.taskNo));
            //if (taskCarrier.des % 10 == 7)
            //{
            //    writeShort(2, (short)(begin + 4), 2);
            //}
            //else
            //{
            //    writeShort(2, (short)(begin + 4), 1);
            //}
            //List<byte> list = new List<byte>();
            //list.AddRange(S7ByteUtil.toS7L4(taskCarrier.taskNo));
            //writeByteArr(15, taskCarrier.src.GetCarrierAddr(), list.ToArray());
            return true;
        }
        public void clearCarrierTask(int begin)
        {
            writeShort(2, (short)(begin + 6), 1);
        }
        public void CarrierWriteStatus(byte value, short addr)
        {
            writeByte(15, addr, value);
        }

        public byte CarrierReadStatus(byte value, short addr)
        {
            return reader(15, addr, 1)[0];
        }

        public void WriteCarrierTaskNo(int stn, int taskNo)
        {
            List<byte> list = new List<byte>();
            list.AddRange(S7ByteUtil.toS7L4(taskNo));
            writeByteArr(15, stn.GetCarrierAddr(), list.ToArray());
        }
    }
}
